if (!jsx3.lang.Class.forName("ux.cdb.admin.loan.LoanManageTebbedpane")) {
/**
 * Define the <code>name of class</code> class.
 * This class inherit from <code>jsx3.gui.Block<code> GUI class.
 */
jsx3.Class.defineClass(
    "ux.cdb.admin.loan.LoanManageTebbedpane",
    ux.megatron.gui.TabbedPane,
    null,
    function (LoanManageTebbedpane) {
    	LoanManageTebbedpane.prototype.homedir = 'ux/cdb/admin/loan/';

		/**
		 * Helper Functions, return a copy function with 
		 * @param fn {Function}
		 * @param scope {Object} 
		 */
		LoanManageTebbedpane.prototype.bind = function(fn, scope) {
			scope = scope || this;
			return function() {
				fn.apply(scope, arguments)
			}
		};
    	
      /**
       * This method will be called after UI file has deserialized.
       */
      LoanManageTebbedpane.prototype.onAfterDeserialize = function() {
	  };
	  
	  LoanManageTebbedpane.prototype.initialize = function() {
      	this.selectRecordId = this.getParent().selectRecordId;
      	this.studentId = this.getParent().studentID;
      	
      	//this.studentId = "1";  //to be delete
      	
      	var me = this;
        var tabLoanInfo = this.get('tabLoanInfo').getContentPane();
        if (!tabLoanInfo.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(tabLoanInfo, "ux.cdb.admin", 
            "ux/cdb/admin/loan/ui/LoanManage_DebitDetailPage.xml", me, me.onDetailLoaded);
        }else{
        	this.onDetailLoaded();
        }
        
        var tabDebitInfo = this.get('tabDebitInfo').getContentPane();
        if (!tabDebitInfo.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(tabDebitInfo, "ux.cdb.admin", 
            "ux/cdb/admin/loan/ui/LoanManage_CoDebitDetailPage.xml", me, me.oncoDetailLoaded);
        }else{
        	this.oncoDetailLoaded();
        }
        
        var StudanBaseInfo = this.get('StudanBaseInfo').getContentPane();
        if (!StudanBaseInfo.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(StudanBaseInfo, "ux.cdb.admin", 
            "ux/cdb/admin/customer/ui/det_baseinfo.xml", me, me.onStudanBaseInfoLoaded);
        }else{
        	this.onStudanBaseInfoLoaded();
        }
        
        var PersonalAccount = this.get('PersonalAccount').getContentPane();
        if (!PersonalAccount.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(PersonalAccount, "ux.cdb.admin", 
            "ux/cdb/admin/customer/ui/det_accinfo.xml", me, me.onPersonalAccountLoaded);
        }else{
        	this.onPersonalAccountLoaded();
        }
        
        var tabStudyInfo = this.get('tabStudyInfo').getContentPane();
        if (!tabStudyInfo.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(tabStudyInfo, "ux.cdb.admin", 
            "ux/cdb/admin/customer/ui/det_studyinfo.xml", me, me.onStudyInfoLoaded);
        }else{
        	this.onStudyInfoLoaded();
        }
        
        var tabEmployInfo = this.get('tabEmployInfo').getContentPane();
        if (!tabEmployInfo.getFirstChild()) {
          ux.megatron.Main.loadUIResourceAsync(tabEmployInfo, "ux.cdb.admin", 
            "ux/cdb/admin/customer/ui/det_careerinfo.xml", me, me.onEmployInfoLoaded);
        }else{
        	this.onEmployInfoLoaded();
        }
      }
      
      LoanManageTebbedpane.prototype.loadTabDetail = function(){
      	this.onDetailLoaded();
      	this.oncoDetailLoaded();
      	this.onStudanBaseInfoLoaded();
      	this.onPersonalAccountLoaded();
      	this.onStudyInfoLoaded();
      	this.onEmployInfoLoaded();
      }
      
      LoanManageTebbedpane.prototype.onDetailLoaded = function(){     	
        var tabLoanInfo = this.get('tabLoanInfo').getContentPane();
        var detail = tabLoanInfo.getDescendantsOfType("ux.cdb.admin.dataautomate.GenericDetail")[0];
        detail.setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Loan);
				detail.setDataEntityId(this.selectRecordId);
				detail.refreshData();
      }      
      LoanManageTebbedpane.prototype.onStudanBaseInfoLoaded = function(){
        var tp = this.get('StudanBaseInfo').getContentPane();
        var detail = tp.getDescendantsOfType("ux.cdb.admin.dataautomate.GenericDetail")[0];
        detail.setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Student);
				detail.setDataEntityId(this.studentId);
				detail.refreshData();
      }
      LoanManageTebbedpane.prototype.onPersonalAccountLoaded = function(){
		var me = this;
		this.get('btnSeeStudyHistory')['onClick'] = this.bind(me.onSeeStudyHistory, me);
		this.get('btnSeeCareerHistory')['onClick'] = this.bind(me.onSeeCareerHistory, me);

        var tp = this.get('PersonalAccount').getContentPane();
        var detail = tp.getDescendantsOfType("ux.cdb.admin.dataautomate.GenericDetail")[0];
        detail.setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Student);
				detail.setDataEntityId(this.studentId);
				detail.refreshData();
      }
      LoanManageTebbedpane.prototype.onStudyInfoLoaded = function(){
        var tp = this.get('tabStudyInfo').getContentPane();
        var detail = tp.getDescendantsOfType("ux.cdb.admin.dataautomate.GenericDetail")[0];
        detail.setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Student);
				detail.setDataEntityId(this.studentId);
				detail.refreshData();
      }
      LoanManageTebbedpane.prototype.onEmployInfoLoaded = function(){
        var tp = this.get('tabEmployInfo').getContentPane();
        var detail = tp.getDescendantsOfType("ux.cdb.admin.dataautomate.GenericDetail")[0];
        detail.setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Student);
				detail.setDataEntityId(this.studentId);
				detail.refreshData();
      }
      
      LoanManageTebbedpane.prototype.oncoDetailLoaded = function() {
        var tp = this.get('tabDebitInfo').getContentPane();
        var detail = tp.getDescendantsOfType("ux.cdb.admin.dataautomate.GenericDetail")[0];
        detail.setDataEntityType(ux.cdb.admin.dataautomate.GenericDetail.Loan);
				detail.setDataEntityId(this.selectRecordId);
				detail.refreshData();
      }
      
      LoanManageTebbedpane.prototype.loadCoDebitData = function() {
        //ux.megatron.Main.loadResource(this.homedir + "xml/CoDebit.xml", "ux.cdb.admin", "loanmanage_0603", "xml");
        //this.CoDebitmatrix.repaint();
      }
		
		LoanManageTebbedpane.prototype.onSeeStudyHistory = function() {
			
			var parent = ux.megatron.Main.getServer().getBodyBlock();
			var me = this;
			this.hisType = "study";
			ux.megatron.Main.loadUIResourceAsync(parent,"ux.cdb.admin","ux/cdb/admin/customer/history/ui/hisDialog.xml", me, me.loadHisDialog);
		};
		
		LoanManageTebbedpane.prototype.onSeeCareerHistory = function() {
			
			var parent = ux.megatron.Main.getServer().getBodyBlock();
			var me = this;
			this.hisType = "career";
			ux.megatron.Main.loadUIResourceAsync(parent,"ux.cdb.admin","ux/cdb/admin/customer/history/ui/hisDialog.xml", me, me.loadHisDialog);
		};
		
		LoanManageTebbedpane.prototype.loadHisDialog = function(objEvent) {
			var hisDialog = objEvent.obj;
			
			hisDialog.studentId = this.studentId;
			hisDialog.hisType = this.hisType;
			hisDialog.loadUI();
		};

	}
  );
}